package entity;

import java.io.Serializable;

public class Order implements Serializable {
    private Integer id;

    private String no;

    private Integer userId;

    private User user;

    private static final long serialVersionUID = 1L;

    public Order(Integer id, String no, Integer userId) {
        this.id = id;
        this.no = no;
        this.userId = userId;
    }

    public Order() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no == null ? null : no.trim();
    }

    public Integer getUserId() {
        if(user!=null){
            this.userId=user.getId();
            return user.getId();
        }
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
        if(user==null){
            this.user=new User();
        }
        user.setId(userId);
    }


    public User getUser() {
        if(user==null&&userId!=null){
            this.user=new User();
            user.setId(userId);
        }
        return user;
    }

    public void setUser(User user) {
        this.user = user;
        if(user!=null){
            this.userId=user.getId();
        }
    }
}